<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=utf-8" errorPage="/error.jsp" isELIgnored="false" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://www.opensymphony.com/oscache" prefix="cache" %>
<%@ taglib uri="http://atleap.blandware.com/taglib" prefix="atleap" %>
<html:xhtml />

<atleap:constants className="com.blandware.atleap.model.questionnaire.Question" scope="page" var="LINE" />
<atleap:constants className="com.blandware.atleap.model.questionnaire.Question" scope="page" var="MULTILINE" />
<atleap:constants className="com.blandware.atleap.model.questionnaire.Question" scope="page" var="DROPDOWN_LIST" />
<atleap:constants className="com.blandware.atleap.model.questionnaire.Question" scope="page" var="RADIO_BUTTONS" />
<atleap:constants className="com.blandware.atleap.model.questionnaire.Question" scope="page" var="CHECK_BOXES" />
<atleap:constants className="com.blandware.atleap.model.questionnaire.Question" scope="page" var="MULTILIST" />

<atleap:content identifier="information" ignore="true" />
<table cellpadding="0" cellspacing="0" border="0" class="tableView">
    <tr>
        <th align="left" width="50%"><atleap:message key="questionnaire.filledQuestionnaire.form.title" /></th>
        <td><atleap:fieldValue valueMap="${questionnaire.title}" filter="true" /></td>
    </tr>
    <tr>
        <th align="left" width="50%"><atleap:message key="questionnaire.filledQuestionnaire.form.date" /></th>
        <td><atleap:formatDate value="${filledQuestionnaire.date}" type="datetime" /></td>
    </tr>
</table>

<atleap:message key="questionnaire.filledQuestionnaire.form.nothingSelected" var="nothingSelectedMsg" />
<table cellpadding="0" cellspacing="0" border="0" class="tableView">
    <tr>
        <th align="center" width="50%">
            <atleap:message key="questionnaire.filledQuestionnaire.form.question" />
        </th>
        <th align="center" width="50%">
            <atleap:message key="questionnaire.filledQuestionnaire.form.answer" />
        </th>
    </tr>
    <atleap:iterator items="${filledQuestionnaire.answers}" var="answer">
        <c:set var="question" value="${answer.question}" />
        <tr>
            <td align="left" width="50%">
                <atleap:fieldValue valueMap="${question.title}" filter="false" />
             </td>
            <td>
                <c:choose>
                    <c:when test="${!question.multiOption}">
                        <c:out value="${answer.text}" escapeXml="true" />
                    </c:when>
                    <c:otherwise>
                        <bean:size id="numberOfOptions" collection="${answer.answerOptions}" />
                        <atleap:iterator items="${answer.answerOptions}" var="answerOption">
                            <atleap:fieldValue valueMap="${answerOption.title}" filter="true" />
                            <br />
                        </atleap:iterator>
                    </c:otherwise>
                </c:choose>
            </td>
        </tr>
    </atleap:iterator>
</table>

<atleap:form action="questionnaire/filledQuestionnaire/list" method="POST" validateOnSubmit="false">
    <atleap:cancel styleClass="button"><atleap:message key="core.commons.buttons.showList" /></atleap:cancel>
</atleap:form>
